﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Globalization;
using Public;

namespace WebsiteAdmin.Wilson.ProInfo.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class ProOtherUpdate : IHttpHandler
    {
        int pkid = 0;
        string bigImgUrl = string.Empty;
        string mediumImgUrl = string.Empty;
        string smallImgUrl = string.Empty;
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Cookie.AdminLoginName != null && Cookie.AdminLoginName != "") 
            {
                InitDate(context);
                int rtn = Update(Global.ConnWilson, pkid, bigImgUrl, mediumImgUrl, smallImgUrl);
                context.Response.Write(rtn == 1 ? "{\"Done\":\"Success\"}" : "{\"Done\":\"Failed\"}");
            }
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        protected void InitDate(HttpContext context) 
        {
            pkid = Convert.ToInt16(context.Request["PKID"], CultureInfo.InvariantCulture);
            bigImgUrl = context.Request["ImgBigURL"];
            mediumImgUrl = context.Request["ImgMediumURL"];
            smallImgUrl = context.Request["ImgSmallURL"];
        }

        protected int Update(string strCon,int pkid,string bigImgUrl,string mediumImgUrl,string smallImgUrl)
        {
            return Bll.ProOtherInfo.Update(strCon, pkid, bigImgUrl, mediumImgUrl, smallImgUrl);
        }
    }
}
